/**
 * 
 */
package com.huilian.security.core.code;

import com.huilian.security.core.code.image.ImageCodeGenerator;
import com.huilian.security.core.code.sms.DefaultSmsCodeSender;
import com.huilian.security.core.properties.SecurityProperties;
import com.huilian.security.sms.SmsCodeSender;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


/**
 * @author: 少凡
 * @Date 2018/1/25
 *
 */
@Configuration
public class ValidateCodeBeanConfig {
	
	@Resource
	private SecurityProperties securityProperties;
	
	@Bean
	@ConditionalOnMissingBean(name = "imageCodeGenerator")
	public ValidateCodeGenerator imageValidateCodeGenerator() {
		ImageCodeGenerator codeGenerator = new ImageCodeGenerator();
		codeGenerator.setSecurityProperties(securityProperties);
		return codeGenerator;
	}
	
	@Bean
	@ConditionalOnMissingBean(SmsCodeSender.class)
	public SmsCodeSender smsCodeSender() {
		return new DefaultSmsCodeSender();
	}

}
